<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const pi = 3.145;   //const 修饰过的不可更改，有点像java中的final

        // pi=3;  报错




        //const的作用域与let命令相同：只在声明所在的块级作用域内有效
        if (true) {
            const MAX = 5;
        }


        MAX // Uncaught ReferenceError: MAX is not defined

        //const命令声明的常量也是不存在提升

        if (true) {
            console.log(MAX); // ReferenceError
            const MAX = 5;
        }

        //const声明的常量，也与let一样不可重复声明
        var message = "Hello!";
        let age = 25;


        // 以下两行都会报错
        const message = "Goodbye!";
        const age = 30;


    </script>
</body>

</html>